/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package khmhappointmentsystem;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JComboBox;

/**
 *
 * @author mbelisle
 */
public class Combo {
     /**
     * This method loads the results of a query into the specified comboBox.
     */
    public static void loadComboValues(String query, JComboBox cmbBox)
    {
        cmbBox.removeAllItems();

        try
        {
            PreparedStatement prep = Environment.getDbConn().prepareStatement(query);
            ResultSet rs = prep.executeQuery();

            while (rs.next())
            {
                cmbBox.addItem(rs.getString(1));
            }
            rs.close();
            prep.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

}
